<template>
  <div class="app-container" style="background-color: #fafafb">
    <el-row type="flex" class="row-bg" justify="center">
      <el-col :span="24">
        <div class="grid-content bg-purple-light">
          <el-card class="box-card" shadow="never" style="margin-top: 0px; min-height: 918px;border:0px;">
            <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
              <el-menu-item index="1" v-permission="'system:project-approval-history:access'">审批历史</el-menu-item>
              <el-menu-item index="2" v-permission="'system:project-info:query'">基本信息</el-menu-item>
              <el-menu-item index="3" v-permission="'system:project-file:query'">附件信息</el-menu-item>
              <el-menu-item index="4" v-permission="'system:house:query'">抵押物信息</el-menu-item>
              <el-menu-item index="6" v-if="itemActiveIndex != '5' " v-permission="'system:credit:query'">征信查询</el-menu-item>
              <el-menu-item index="7" v-if="itemActiveIndex != '5' " v-permission="'system:check-opinion:query'">尽调详情</el-menu-item> <!-- 审查信息 -->
              <!-- <el-menu-item index="8" v-if="itemActiveIndex != '5' && projectStatus > 23" v-permission="'system:comfirmed:query'">确认信息</el-menu-item> -->
              <el-menu-item index="8" v-if="itemActiveIndex != '5'" v-permission="'system:comfirmed:query'">确认信息</el-menu-item>
              <el-menu-item index="9" v-if="itemActiveIndex != '5'" v-permission="'system:contract:access'">合同信息</el-menu-item>
              <el-menu-item index="36" v-if="itemActiveIndex >= 23 && itemActiveIndex!='34'" >审批结果</el-menu-item><!--(审批结果)待确认-->
              <el-menu-item index="37" v-if="itemActiveIndex >= 23 && itemActiveIndex !='35'" v-permission="'system:final-review-result:query'">终审结果</el-menu-item><!--（终审结果）待确认-->
              <el-menu-item index="5" v-if="itemActiveIndex === '5' && ifReceive === '1'" v-permission="'system:task-first-check:view'">业务初审</el-menu-item><!--待处理-->
              <el-menu-item index="10" v-if="itemActiveIndex === '10' && ifReceive === '1'" v-permission="'system:task-wait-review:view'">业务复审</el-menu-item><!--待审查-->
              <el-menu-item index="15" v-if="itemActiveIndex === '15' && ifReceive === '1'" v-permission="'system:task-delivery-check:view'">分配结果</el-menu-item><!--待派件-->
              <el-menu-item index="20" v-if="itemActiveIndex === '20' && ifReceive === '1'" v-permission="'system:task-wait-due-diligence:view'">尽调结果</el-menu-item><!--待尽调-->
              <el-menu-item index="22" v-if="itemActiveIndex === '22' && ifReceive === '1'" v-permission="'system:task-approve-check:view'">审批结果</el-menu-item><!--待审批-->
              <el-menu-item index="23" v-if="itemActiveIndex === '23' && ifReceive === '1'" v-permission="'system:task-to-be-comfirmed:view'">确认结果</el-menu-item><!--待确认-->
              <el-menu-item index="231" v-if="itemActiveIndex === '231' && ifReceive === '1'" v-permission="'system:task-to-be-comfirmed:view'">确认结果</el-menu-item><!--待确认-->
              <el-menu-item index="24" v-if="itemActiveIndex === '24' && ifReceive === '1'" v-permission="'system:task-sign-check:view'">签署结果</el-menu-item><!--待签约-->
              <el-menu-item index="26" v-if="itemActiveIndex === '26' && ifReceive === '1'" v-permission="'system:task-notary-review:view'">公证结果</el-menu-item>
              <el-menu-item index="27" v-if="itemActiveIndex === '27' && ifReceive === '1'" v-permission="'system:task-pledge-check:view'">办押结果</el-menu-item>
              <el-menu-item index="28" v-if="itemActiveIndex === '28' && ifReceive === '1'" v-permission="'system:task-loan-check:view'">请款结果</el-menu-item>
              <el-menu-item index="18" v-if="itemActiveIndex === '18' && ifReceive === '1'" v-permission="'system:task-fill-material:view'">补充资料结果</el-menu-item>
              <el-menu-item index="102" v-if="itemActiveIndex === '102' && ifReceive === '1'" v-permission="'system:task-return-step-add:view'">退件结果</el-menu-item>
              <el-menu-item index="90" v-if="itemActiveIndex === '90'" v-permission="'system:loan-result-list:view'">请款结果</el-menu-item>
              <el-menu-item index="34" v-if="itemActiveIndex === '34' && ifReceive === '1'"  v-permission="'system:task-wait-verifyied:view'">核查结果</el-menu-item>
              <el-menu-item index="35"  v-if="itemActiveIndex === '35' && ifReceive === '1'" v-permission="'system:task-final-review:view'">终审结果</el-menu-item>
            </el-menu>
            <!--子组件展示-->
            <div style="margin: 50px">
              <ProjectApprovalHistory :projectId="projectId" v-if="activeIndex === '1'" />
              <Info :projectId="projectId" :taskId="taskId" :operationLook="operationLook" @getCapitalTrue="getCapitalTrue" @getCapital="getCapital" :taskData="taskData" :taskDataCheck="taskDataCheck"  :projectStatus="18" v-if="activeIndex === '2'" />
              <File changeValue="detail" :projectId="projectId" :taskId="taskId" :realName="realName" :operationLook="operationLook" :projectStatus="projectStatus" v-if="activeIndex === '3'" />
              <HouseInfo :projectId="projectId" :taskId="taskId" @getCapitalTrue="getCapitalTrue" @getCapital="getCapital"  :projectStatus="projectStatus"  :operationLook="operationLook" v-if="activeIndex === '4'" />
              <Credit :projectId="projectId" :taskId="taskId" :operationLook="operationLook" v-if="activeIndex === '6'" />
              <Review :projectId="projectId" :taskId="taskId" :operationLook="operationLook" v-if="activeIndex === '7'" />
              <ConfirmInfo :projectId="projectId" v-if="activeIndex === '8'" />
              <Contract :projectId="projectId" :operationLook="operationLook" v-if="activeIndex === '9'" />
              <ApproveCheckManage :projectId="projectId" :taskId="taskId"  v-if="activeIndex === '36'" /><!--审批结果（待确认）-->
              <FianlJudmentManage :projectId="projectId" :taskId="taskId"  v-if="activeIndex === '37'" /><!--终审结果（待确认）-->
              <FirstCheck :projectId="projectId" :taskId="taskId" v-if="activeIndex === '5' && ifReceive === '1'" /><!--待处理-->
              <WaitReview :projectId="projectId" :taskId="taskId" v-if="activeIndex === '10' && ifReceive === '1'" /><!--待审查-->
              <DeliveryCheck :projectId="projectId" :taskId="taskId" :appointNextTime="appointNextTime" v-if="activeIndex === '15' && ifReceive === '1'"/><!--待派件-->
              <WaitDueDiligence :projectId="projectId" :taskId="taskId" v-if="activeIndex === '20' && ifReceive === '1'" /><!--待尽调-->
              <ApproveCheck :projectId="projectId" :taskId="taskId" v-if="activeIndex === '22' && ifReceive === '1'"/><!--待审批-->
              <ToBeComfirmed :projectId="projectId" :taskId="taskId" v-if="activeIndex === '23' && ifReceive === '1'" /><!--待确认-->
              <ToBeComfirmed :projectId="projectId" :taskId="taskId" v-if="activeIndex === '231' && ifReceive === '1'" /><!--待确认-->
              <SignCheck :projectId="projectId" :taskId="taskId" v-if="activeIndex === '24' && ifReceive === '1'" /><!--待签约-->
              <NotaryCheck :projectId="projectId" :taskId="taskId" v-if="activeIndex === '26' && ifReceive === '1'" /><!--待公证-->
              <PledgeCheck :projectId="projectId" :taskId="taskId" v-if="activeIndex === '27' && ifReceive === '1'" /><!--待办押-->
              <LoanCheck :projectId="projectId" :taskId="taskId" v-if="activeIndex === '28' && ifReceive === '1'" /><!--待请款-->
              <FillMaterial :projectId="projectId" :taskId="taskId" v-if="activeIndex === '18' && ifReceive === '1'" /><!--补资料-->
              <ReturnStep :projectId="projectId" :taskId="taskId" v-if="activeIndex === '102' && ifReceive === '1'" /><!--退件-->
              <LoanResult :projectId="projectId" :taskId="taskId" v-if="activeIndex === '90'" /><!--请款结果-->
              <ToBeVerified :projectId="projectId" :taskId="taskId" v-if="activeIndex === '34' && ifReceive === '1'" /><!--待核查-->
              <FianlJudment :projectId="projectId" :taskId="taskId"  v-if="activeIndex === '35' " /><!--终审结果-->
            </div>
          </el-card>
        </div></el-col
      >
    </el-row>
  </div>
</template>


<script>
import ProjectApprovalHistory from '@/views/task/task_detail/project_approval_history';
import File from '@/views/project/file';
import HouseInfo from '@/views/task/houseInfo';
import Review from '@/views/task/review';
import Info from '@/views/task/info';
import Credit from '@/views/task/credit';
import ConfirmInfo from '@/views/task/task_detail/confirmInfo';
import Contract from '@/views/task/task_detail/contract';
import FirstCheck from '@/views/task/task_detail/firstCheck';
import WaitReview from '@/views/task/task_detail/waitReview';
import DeliveryCheck from '@/views/task/task_detail/deliveryCheck';
import WaitDueDiligence from '@/views/task/task_detail/waitDueDiligence';
import ApproveCheck from '@/views/task/task_detail/approveCheck';
import ToBeComfirmed from '@/views/task/task_detail/toBeComfirmed';
import SignCheck from '@/views/task/task_detail/signCheck';
import NotaryCheck from '@/views/task/task_detail/notaryCheck';
import PledgeCheck from '@/views/task/task_detail/pledgeCheck';
import LoanCheck from '@/views/task/task_detail/loanCheck';
import FillMaterial from '@/views/task/task_detail/fillMaterial'; //补资料
import ReturnStep from '@/views/task/task_detail/returnStepAdd'; //退件
import LoanResult from '@/views/task/task_detail/loanResult'; // 请款结果
import ToBeVerified from "@/views/task/task_detail/toBeVerified"; //待核查
import FianlJudment from "@/views/task/task_detail/fianlJudment"; //终审结果
import FianlJudmentManage from "@/views/task/task_detail/fianlJudmentManage"; //终审结果查看
import ApproveCheckManage from '@/views/task/task_detail/approveCheckManage'; //审批结果查看
import {getProjectKey} from '@/utils/index'
import {findProjectBytId} from '@/api/project';
import {caitalList } from '@/api/projectFile'
export default {
  name: 'add',
  components: {
    ProjectApprovalHistory,
    File,
    HouseInfo,
    Review,
    Info,
    Credit,
    ConfirmInfo,
    Contract,
    FirstCheck,
    WaitReview,
    DeliveryCheck,
    WaitDueDiligence,
    ApproveCheck,
    ToBeComfirmed,
    SignCheck,
    NotaryCheck,
    PledgeCheck,
    LoanCheck,
    FillMaterial,
    ReturnStep,
    LoanResult,
    ToBeVerified,
    FianlJudment,
    FianlJudmentManage,
    ApproveCheckManage
  },
  data() {
    return {
      activeIndex: '1',
      itemActiveIndex: '1',
      name: '11',
      projectId: undefined,
      projectStatus: undefined,
      taskId: undefined,
      appointNextTime: undefined,
      ifReceive: undefined,
      operationLook: undefined,
      realName:undefined,
      projectKey:undefined,
      taskDataCheck:[],
      taskData:[]
    };
  },
  computed: {},
  created() {
    this.projectId = this.$route.query.projectId
    this.projectStatus = this.$route.query.projectStatus
    this.taskId = this.$route.query.taskId
    this.appointNextTime = this.$route.query.appointNextTime
    this.ifReceive = ''+this.$route.query.ifReceive+''
    this.operationLook = this.$route.query.operationLook
    this.realName = this.$route.query.realName
    console.log('projectStatus--' + this.projectStatus)
    console.log('ifReceive:' + this.ifReceive)
    this.findByProjectId()
    if (this.ifReceive == 0) {
      // 已处理的任务默认展示第一个
      this.activeIndex == '1';
    } else {
      if (this.projectStatus != undefined) {
        this.itemActiveIndex = '' + this.projectStatus + ''
        this.activeIndex = '' + this.projectStatus + ''
        console.log(this.ifReceive)
      }
    }
    //点击详情进来
    let lookIndex = this.$route.query.activeIndex
    if( lookIndex != undefined ) {
      this.activeIndex = lookIndex
    }
    // this.getCapitalTrue()
    // this.getCapital()
  },
  methods: {
    stepChange(currentStep) {
      this.currentStep = currentStep;
    },
    handleSelect(val) {
      this.activeIndex = val;
    },
    matchState(state='',reg) {
      return !!String(state).match(reg)
    },
    findByProjectId() {
      findProjectBytId({projectId:this.projectId})
        .then(response => {
          if(response.data != undefined ) {
           console.log(response.data)
           let key = getProjectKey(response.data.processKey)
           this.projectKey = key
          }
        })
        .catch(() => {
        })
    },
    getCapital() {
      caitalList({projectId:this.projectId})
        .then(res => {
          this.taskData = res.data
          
        })
        .catch(() => {
          this.taskData =[]
        })
    },
    getCapitalTrue() {
      caitalList({projectId:this.projectId,checkStatus:true})
        .then(res => {
          this.taskDataCheck = res.data
          
        })
        .catch(() => {
          this.taskDataCheck =[]
        })
    },
  },
};
</script>



